new Vue ({
	el: "#app", 
	data: {
		imgUrl: "https://app.meijiangzi.com/static/mini_",
		search_content: "",
		type: 1,
		longitude: "",
		latitude: "",
		page: 1,
		total: "",
		project_list: [],
		goods_list: [],
		isbottom: !1,
		isempty: !1,
		isFocus: !0,
		province: 61,
		province_id: 61,
		searchHistory: !1,
		search_content_array1: [],
		search_content_array2: [],
		isExcute: false
    },
	methods: {
	    search: function(t) {
			var s = this;
			if ("" == this.search_content) return !1;
			-1 == this.search_content_array1.indexOf(this.search_content) && 1 == this.type && (this.search_content_array1.length >= 10 && this.search_content_array1.splice(0, 1), 
			this.search_content_array1.push(this.search_content), wx.setStorageSync("searchHistory1", JSON.stringify(this.search_content_array1))), 
			-1 == this.search_content_array2.indexOf(this.search_content) && 2 == this.type && (this.search_content_array2.length >= 10 && this.search_content_array2.splice(0, 1), 
			this.search_content_array2.push(this.search_content), wx.setStorageSync("searchHistory2", JSON.stringify(this.search_content_array2))), 
			wx.showLoading({
				title: "加载中",
				mask: !0
			}), this.searchHistory = !1;
			var a = void 0, e = void 0;
			0 == this.type ? (a = { 
				page: this.page,
				pageSize: 10,
				lat: this.latitude,
				lng: this.longitude,
				province_id: this.province_id,
				keyword: this.search_content,
				type: this.type
			}, e = "api/v2_5/home/search") : (a = {
				currentPage: this.page,
				pageSize: 10,
				lat: this.latitude,
				lng: this.longitude,
				// zoneCode: this.province_id,
				projectName: this.search_content
			  }, 1 == this.type ? e = "api/project/list" : 2 == this.type && (e = "wap/product/index") && (a={
				currentPage: this.page,
				pageSize: 10,
				name:this.search_content
			}));
			this.$http.post(baseUrl+e, a).then(function(t) {
				wx.hideLoading();
				var a = t.data;
				var i = a.data[0];
				if (!a.success) return wx.hideLoading(), wx.showToast({
					title: a.description,
					icon: "none",
					duration: 2e3,
					mask: !0
				}), !1;
				if (0 == a.data.length && s.page > 1) return wx.hideLoading(), wx.showToast({
				  title: "已经没有更多了",
				  icon: "none",
				  duration: 1500,
				  mask: !1
				}), t.isbottom = !0;
				0 == a.data.length ? (s.project_list = [], s.goods_list = [], s.isempty = !0) : (1 == s.type ? (s.project_list = a.data, 
				  s.total = a.total) : (s.goods_list = a.data, s.total = a.total,
				  s.goods_list.forEach(function (e) {
					e.product = JSON.stringify(e);
					e.homePath = e.logoPath.split(",")[0];
				  })), 
				  s.isempty = !1, s.total = a.total);
				  this.isExcute = false;
			}).catch(function(t) {
				wx.hideLoading(), wx.showToast({
					title: "网络错误，请稍后重试",
					icon: "none",
					duration: 2e3,
					mask: !1
				});
			})
		},
		clickSearchContent: function(t) {
			var s = this;
			this.search_content = t, setTimeout(function() {
				s.search();
			}, 1e3);
		},
		get_position: function() {
			var t = this;
			t.longitude = wx.getStorageSync("userLng"), t.latitude = wx.getStorageSync("userLat");
		},
		del: function() {
			localStorage.del("searchHistory1"), this.search_content_array1 = [];
		},
	    toMalldetail: function(t) {
	        Jump.to(page.index.detail, "id=" + t.guid);
	    },
	    scroll: function(t) {},
	    pullrefresh: function(t) {
	        this.page++, this.search();
	    },
		handleScroll: function(){
			// 防止重复
			if (this.isExcute) {
				return;
			}
			if (this.isbottom) {
				return;
			}
			var flag = srollEvent.isReachBottom();
			if (!flag) {
				return;
			}
			this.isExcute = true;
			this.pullrefresh();
		},
	    get_location: function() {
	        var t = this;
	      t.longitude = wx.getStorageSync("userLng"), t.latitude = wx.getStorageSync("userLat");
	    }
	},
	mounted: function() {
		window.addEventListener("scroll", this.handleScroll, {
			passive: false
		});
	},
	created: function() {
		this.province = JSON.parse(wx.getStorageSync("province_info")).province_name, 
		this.get_position(), wx.getStorageSync("searchHistory1") && (this.searchHistory = !0, 
		this.search_content_array1 = JSON.parse(wx.getStorageSync("searchHistory1"))), wx.getStorageSync("searchHistory2") && (this.searchHistory = !0, 
		this.search_content_array2 = JSON.parse(wx.getStorageSync("searchHistory2")));
		var province_info = wx.getStorageSync("province_info");
		province_info && (this.province_id = JSON.parse(province_info).province_id);
	}
});